$(function() {
   	   $("#clearTax1,#clearTax2,#clearDrainage").click(function(){
   		   var gameId = $(this).attr("gameId");
   		   var type = $(this).attr("type");
   		   var roomId = $(this).attr("roomId");
   		   var toId = $(this).attr("toId");
   		   var val = $.trim($(toId).text());
   		   if(null == val || "" == val){
   			   val = 0;
   		   }else{
   			   val = parseInt(val);
   		   }
   		   var data = {
   				gameId:gameId,
   				type:type,
   				roomId:roomId,
   				val:val 
   	        };
	   		layer.confirm("确认清空吗？", 
		    	    function(confirmIndex){
				      layer.close(confirmIndex);
				      var loadingIndex = layer.msg('正在清空操作..', {shade:0.00001,icon: 16,time: 1000*60*10 });
		    		  $.ajax({
		    	    		type:"POST", 
		    	    		url:"taxClear/add",
		    	    		data:data,
		    	    		dataType:"json",
		    	    		error:function(){
		    	    			layer.close(loadingIndex);
		    	    			layer.msg('清空操作失败！');
		    	    		},
		    	    		success:function(data){
		    	    			layer.close(loadingIndex);
		    	    			if(data.result){
		    	    				$(toId).text(0);
		    	    				layer.msg('操作成功！');
		    		 			}else{
		    		 				layer.msg('清空操作失败！');
		    		 			}
		    	    		}
		    	    	});
		    		}, function(confirmIndex){
		    			layer.close(confirmIndex);
		    	    }
		    );
   	   });
});
